# -*- coding: utf-8 -*-
"""
Created on Wed Aug 07 19:29:42 2013

@author: Jeanhwea
"""
import simplejson, urllib
GEOCODE_BASE_URL = 'http://maps.googleapis.com/maps/api/geocode/json'
def geocode(address,sensor, **geo_args):
    geo_args.update({
        'address': address,
        'sensor': sensor  
    })
    url = GEOCODE_BASE_URL + '?' + urllib.urlencode(geo_args)
    result = simplejson.load(urllib.urlopen(url))
    print simplejson.dumps([s['formatted_address'] for s in result['results']], indent=2)
if __name__ == '__main__':
    geocode(address="Hedian+Wuwei+Anhui",sensor="false")